<!--
 * @description  :情报线索登记文书详情
 * @descriptionDetail:情报线索登记文书详情
 * @copyright    : 浙江烟草
 * @author       : dw
 * @create       : 2022-10-16 13:18:15
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="navTitle" style="z-index: 99999">
    </theme-navbar>
    <!-- #endif -->
    <view class="content u-page" :class="actionBtns.length > 0 ? 'content-padding-bottom':''">
      <u-form ref="uForm" :model="addForm" label-position="top" label-width="auto" :error-type="['border-bottom']">
        <u-form-item
          label="接收时间"
          prop="regDate"
          :right-icon="!justView ? 'calendar' : ''"
          :required="!justView"
          :rightIconStyle="rightIconStyle"
        >
          <u-input placeholder="系统获取当前时间"  :needValid="!justView" :disabled="true" :custom-style="pointerStyle" v-model="addForm.regDate" @click="clickRegDate">
          </u-input>
        </u-form-item>
        <u-form-item
          label="来源途径"
          :rightIcon="!justView ? 'arrow-right' : ''"
          :required="!justView"
          prop="sourceType"
          :rightIconStyle="rightIconStyle"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.SOURCE_TYPE"
            :dicCode="addForm.sourceType"
            :border="false"
            type="text"
            :needValid="!justView"
            :select-open="dicSelectOpen('sourceType',$u.dic.DIC_KEYS.SOURCE_TYPE)"
            placeholder="请选择"
            :disabled="true"
            v-model="addForm.sourceTypeName"
            @changeInputModelData="(name)=>{$set(addForm, 'sourceTypeName', name)}"
            @click="showDic($u.dic.DIC_KEYS.SOURCE_TYPE,addForm.sourceType,'sourceType')"
          />
        </u-form-item>
        <u-form-item
          label="举报形式"
          :rightIcon="!justView ? 'arrow-right' : ''"
          :required="!justView"
          prop="reportType"
          :rightIconStyle="rightIconStyle"
        >
          <dic-input
            :keyWord="$u.dic.DIC_KEYS.REPORT_STYLE"
            :dicCode="addForm.reportType"
            :border="false"
            type="text"
            :select-open="dicSelectOpen('reportType',$u.dic.DIC_KEYS.REPORT_STYLE)"
            placeholder="请选择"
            :needValid="!justView"
            :disabled="true"
            v-model="addForm.reportTypeName"
            @changeInputModelData="(name)=>{$set(addForm, 'reportTypeName', name)}"
            @click="showDic($u.dic.DIC_KEYS.REPORT_STYLE,addForm.reportType,'reportType')"
          />
        </u-form-item>

        <u-form-item label="是否举报" label-position="left" :border-bottom="false">
          <u-switch slot="right" :disabled="justView || from == 2" v-model="addForm.isReport"></u-switch>
        </u-form-item>
	
        <u-form-item label="">
          <text class="title-gp">
            如此线索为举报，则需要勾选，在待指派环节需要生成举报记录表
          </text>
        </u-form-item>
		<u-form-item label="领取举报奖励" label-position="left" v-if="addForm.isReport">
		  <u-switch slot="right" :disabled="justView || from == 2" v-model="addForm.isReceiveAward"></u-switch>
		</u-form-item>
        <u-form-item v-show="showAcceptNo" label="受理编号" :required="!justView" prop="acceptNo">
          <u-input type="text" :disabled="justView" v-model="addForm.acceptNo" :placeholder="justView ? '':'请输入12313受理编号'">
          </u-input>
        </u-form-item>
        <u-form-item label="举报人描述">
          <u-input type="textarea" :disabled="justView" v-model="addForm.reportPersonDesc" :placeholder="justView ? '':'请输入举报人描述'">
          </u-input>
        </u-form-item>
        <u-form-item label="情报描述" :required="!justView" prop="name">
          <u-input type="textarea" maxlength="340" :disabled="justView" v-model="addForm.name" :placeholder="justView ? '':'请输入情报描述'">
          </u-input>
        </u-form-item>
        <u-form-item label="登记人意见" :required="!justView || from == 2" prop="undertakerAdvice">
          <u-input type="textarea" maxlength="340" :disabled="justView && from != 2" v-model="addForm.undertakerAdvice" :placeholder="justView ? '':'请输入登记人意见'">
          </u-input>
        </u-form-item>
        <u-form-item label="备注">
          <u-input type="textarea" maxlength="340" :disabled="justView" v-model="addForm.remark" :placeholder="justView ? '':'请输入备注信息'">
          </u-input>
        </u-form-item>
        <u-form-item label="附件">
          <m-upload
            :uploadParam="fileUploadParam"
            upApiUrl="uploadBase64ForApp"
            v-if="recordItem.uuid"
            :fileList="fileList"
            :disabled="justView"
            :deletable="!justView"
            @on-list-change="changeUpload"
          ></m-upload>
          <span v-else style="color: red">请先保存线索，后再上传附件</span>
        </u-form-item>
      </u-form>
    </view>
    <view v-if="actionBtns.length > 0" class="submit-btns btn-other-cls">
      <u-button v-for="itm in actionBtns" class="u-btn" :type="itm.type" :plain="itm.plain" :key="itm.action" @click="btnAction(itm.action)">
        {{ itm.text }}
      </u-button>
    </view>
    <u-picker v-model="dateShow" mode="time" :params="pickerParams" @confirm="changeDate"></u-picker>
    <!-- 下拉选择用 -->
    <dic-choice
      :keyWord="dicKeyWords"
      :currentSelect="dicCurrentSelect"
      v-model="dicShow"
      @confirm="selectDicConfirm"
    ></dic-choice>
    <!-- 派发组织机构选择 -->
    <u-popup mode="bottom" height="60%" v-model="downOrgVisible">
      <org-select treeType="zm-comp" :hasVirtual="true" :parentUuid="user.provOrgUuid" limitNodeType="03" @choose="orgSelected"></org-select>
    </u-popup>
    <!-- 派发市管员 -->
    <u-popup mode="bottom" height="60%" v-model="marketManagerVisible">
      <org-person-select :isSingle="true" :defaultOrgUuid="user.user.org.orgUuid" treeType="zm-user" @choose="marketManagerSelect"></org-person-select>
    </u-popup>
    <!-- 市管调查 -->
    <u-popup mode="bottom" height="60%" v-model="investVisible">
      <invest-component :curRecord="recordItem" @confirm="investHandle"></invest-component>
    </u-popup>
    <!-- 反馈记录 -->
    <u-popup mode="bottom" height="80%" v-model="feedbackVisible">
      <feed-back-his-component :record="recordItem" @close="() => feedbackVisible = false"></feed-back-his-component>
    </u-popup>
  </view>
</template>

<script>
import inteligenceService from '@/service/intelligence/intelligence.service.js';
import DicChoice from "@/components/dic_choice.vue";
import DicInput from "@/components/dic_input.vue";
import {uuid,} from "@/common/util.js";
import {INTELLIGENCE_STATUS,S_DOC_STATUES,} from "@/service/intelligence/mapping/enum.js";
import OrgSelect from "@/components/org-select.vue";
import OrgPersonSelect from "@/components/org-person-select.vue";
import InvestComponent from "../components/investComponent.vue";
import FeedBackHisComponent from "../components/feedBackHisComponent.vue";
import { CASE_TYPE, } from '@/service/case/mapping/index.js';
import MUpload from "@/components/m-upload.vue";
import intelligenceservice from "@/service/intelligence/intelligence.service";
import {INVEST_STATUS,K_CLUE_RESULT,K_SOURCE_TYPE,C_REPORT_STYLE,} from '@/service/intelligence/mapping/enum.js';
export default {
  components: {
    DicChoice,
    DicInput,
    OrgSelect,
    InvestComponent,
    FeedBackHisComponent,
    OrgPersonSelect,
    MUpload,
  },
  data() {
    return {
      user: this.$store.state.userInfo,
      childOrgs:[],
      downOrgVisible:false, // 选择直属下属部门
      marketManagerVisible:false,
      investVisible:false,
      feedbackVisible:false,
      topSelf:"",
      fromType:"register",  // register 情报登记  feedback 情报反馈
      from : 0, // 0 是新增  1是 修改  2 是接办
      addForm:{
        isReport:false,
		isReceiveAward:false,
        remark:"",
      },
      dicKeyWords: "",
      dicCurrentSelect: "",
      dicShow: false,
      dicType: "",
      pickerParams:{
        year: true,
        month: true,
        day: true,
        hour: true,
        minute: true,
        second: true,
        // 选择时间的时间戳
        timestamp: true,
      },
      fileUploadParam:{
        fiGroupCode:this.$FILE_GROUP_TYPE.JNSG_PIC,
        bizId:"",
      },
      fileList:[],
      rules:{
        regDate: [{
          required: true,
          message: '请选择接收时间',
          // 可以单个或者同时写两个触发验证方式
          trigger: ['change', 'blur',],
        },],
        sourceType: [{
          required: true,
          message: '请选择来源途径',
          // 可以单个或者同时写两个触发验证方式
          trigger: ['change', 'blur',],
        },],
        reportType:[
          {
            required: true,
            message: '请选择举报形式',
            // 可以单个或者同时写两个触发验证方式
            trigger: ['change', 'blur',],
          },
        ],
        name: [{
          required: true,
          message: '请输入情报描述',
          // 可以单个或者同时写两个触发验证方式
          trigger: ['change', 'blur',],
        },],
        undertakerAdvice: [{
          required: true,
          message: '请输入登记人意见',
          // 可以单个或者同时写两个触发验证方式
          trigger: ['change', 'blur',],
        },],
        acceptNo: [
          {
            // 自定义验证函数，见上说明
            validator: (rule, value, callback) => {
              if(this.showAcceptNo){
                return !this.$u.test.isEmpty(value);
              }else{
                return true;
              }
            },
            message: '请输入12313受理编号',
            // 触发器可以同时用blur和change
            trigger: ['change','blur',],
          },
        ],
      },
      rightIconStyle: {
        fontSize: "40rpx",
      },
      dateShow:false,
      recordItem: {
        uuid:'',
      },
      actionBtns:[],
      regCaseType:'case-simple',
      taskId: "",
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx start
			pointerStyle: {
			  marginRight: "5px",
				pointerEvents: "none !important"
			},
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx end
    }
  },
  onLoad(opt) {
    this.showDefaultTitle = false;
    this.fromType = opt.fromType || '';
    this.from = opt.from;
    this.taskId = opt.taskId || '';
    this.topSelf = opt.topSelf || "";
    this.recordItem = this.getRouteParam() || {};
    if (this.recordItem) {
      this.fileUploadParam.bizId = this.recordItem.uuid;
      let params = {
        bizId: this.recordItem.uuid,
        group: this.$FILE_GROUP_TYPE.JNSG_PIC,
        menuCode: null,
      };
      intelligenceservice.findFilesByBizIdAndGroup(params).then(res => {
        if(res.success){
          this.fileList = res.data;
        }
      })
    } else {
      this.recordItem.uuid = uuid();
      this.fileUploadParam.bizId = this.recordItem.uuid;
    }
    console.log(this.recordItem)
  },
  computed: {
    justView() {
      return  !this.$u.test.isEmpty(this.recordItem.status) && this.recordItem.status != INTELLIGENCE_STATUS.DRAFT.value;
    },
    showAcceptNo(){
      return K_SOURCE_TYPE.ST_06 == this.addForm.sourceType;
    },
  },
  onReady() {
    this.$refs.uForm.setRules(this.rules);
  },
  created() {
    if(this.from == 1){
      this.updateMixinTitle('情报线索编辑');
    }else if(this.from == 2){
      this.updateMixinTitle('线索接收登记');
    }else{
      this.updateMixinTitle('情报线索登记');
    }
    this.init();
  },
  methods: {
    init(){
      if(this.from == 1 || this.from == 2){ // 表示修改
        if(this.from == 1 && this.recordItem.transFlag && this.fromType !== 'feedback' && this.recordItem.current){
          this.from = 2;
        }
        this.addForm.isReport =  this.recordItem.isReport * 1 === 1;
		this.addForm.isReceiveAward = this.recordItem.isReceiveAward * 1 === 1;
        this.addForm.menuCode = "";
        this.addForm.name =  this.recordItem.name;
        this.addForm.regDate =  this.recordItem.regDate;
        this.addForm.remark =  this.recordItem.remark || "";
        this.addForm.reportPersonDesc =  this.recordItem.reportPersonDesc;
        this.addForm.reportType =  this.recordItem.reportType;
        this.addForm.sourceType =  this.recordItem.sourceType;
        this.addForm.acceptNo = this.recordItem.acceptNo || '';
        this.addForm.reportTypeName =  this.recordItem.reportTypeName || "";
        this.addForm.sourceTypeName =  this.recordItem.sourceTypeName || "";
        this.addForm.undertakerAdvice =  this.recordItem.undertakerAdvice;
        this.addForm.uuid =  this.recordItem.uuid || '';
      }else{
        this.addForm.uuid = "";
        this.addForm.isReport =  false;
      }
      // this.loadOrgData();
      this.getUpdateActionBtns();
    },
    changeDate(e){
      this.$set(this.addForm,'regDate', this.$u.date(e.timestamp, "yyyy年mm月dd日 hh时MM分ss秒"));
    },
    clickRegDate(){
      if(this.justView) return;
      this.dateShow = true;
    },
    selectDicConfirm(e) {
      if (this.dicKeyWords == this.$u.dic.DIC_KEYS.SOURCE_TYPE) {
        this.$set(this.addForm,'sourceTypeName', e[0].label);
        this.$set(this.addForm,'sourceType', e[0].extra.bcbCode);
        if(K_SOURCE_TYPE.ST_06 != this.addForm.sourceType){
          this.addForm.acceptNo = "";
        }
      }else if(this.dicKeyWords == this.$u.dic.DIC_KEYS.REPORT_STYLE){
        this.$set(this.addForm,'reportTypeName', e[0].label);
        this.$set(this.addForm,'reportType', e[0].extra.bcbCode);
        let rOther = C_REPORT_STYLE.REPORT_4108;
        if(e[0].label !== rOther) {
          this.addForm.isReport = true;
        } else {
          this.addForm.isReport = false;
        }
      }
    },
    showDic(key, cur, type) {
      if (this.dicShow || this.justView) return;
      this.dicKeyWords = key;
      this.dicCurrentSelect = cur;
      this.dicShow = true;
      this.dicType = type;
    },
    dicSelectOpen(type, keyWords) {
      if (type == this.dicType) {
        if (this.dicKeyWords == keyWords && this.dicShow) {
          return true;
        }
        return false;
      }
    },
    // 上传/删除图片事件
    changeUpload(list, key){
      if(list.length > 0){
        this.fileList = [...list,];
      }else{
        this.fileList = [];
      }
    },
    orgSelected(orgs){
      if(this.recordItem == undefined || orgs == undefined) return;
      let org = orgs[0];
      if(org.nodeType != '03' && org.id != this.topSelf) {
        this.$u.toast('请选择县局专卖局或者省局专卖局');
        return ;
      }
      this.downOrgVisible = false;
      this.doTransfer("是否将此线索转交给【" + org.name + "】",this.recordItem,'trans',org.id);
    },
    marketManagerSelect(e){
      let p = e || [];
      if(p.length == 0) {
        this.$u.toast('请选择调查人员');
        return ;
      }
      this.$modal.showLoading('正在指派...');
      inteligenceService.pointManager({
        uuid: this.recordItem.uuid,
        investPersonUuid: p[0].id,
        investPersonName: p[0].name,
        managerOrgUuid: p[0].pId,
      }).then(res => {
        this.$modal.hideLoading();
        if(res.success) {
          this.marketManagerVisible = false;
          this.backPrev({
            paramKey:"refresh",
            param: true,
          });
        } else {
          this.$u.toast(res.msg);
        }
      }).catch(e => {
        this.$modal.hideLoading();
        this.$u.toast('指派失败:' + e);
        console.log(e);
      });
    },
    investHandle(f){
      if(f){
        this.investVisible = false;
        if(f.result == INVEST_STATUS.INVEST_01){ // 立案
          this.recordItem = f;
          this.getUpdateActionBtns();
          this.btnAction("immediateInvestigation", true);
        }else{ // 非立案
          this.backPrev({
            paramKey:"refresh",
            param: true,
          });
        }
      }
    },
    showMarketManager () {
      //  指派调查人..需要先判断当前记录是否有举报记录表..
      if(this.recordItem.isReport) {
        let report = this.recordItem.clueReports || [];
        console.log(this.recordItem)
        // 找到本单位的举报记录表..并且是进行中的 或者已完成的..
        report = report.filter(r => r.orgUuid === this.recordItem.curOrgUuid 
		&& (r.handleStatus === S_DOC_STATUES.DOING 
		|| r.handleStatus ===  S_DOC_STATUES.FINISHED) );
        if(report.length === 0 ) {
          this.$modal.confirm("当前未发现本单位进行中或已完成的举报记录表，是否先制作", () => {
            this.doInitReport();
          });
          return false;
        }
      }
      this.marketManagerVisible = true;
    },
    doInitReport () {
      this.$modal.showLoading('加载中...');
      inteligenceService.initReport({typeCode:'qbcz',clueUuid: this.addForm.uuid,}).then(res => {
        this.$modal.hideLoading();
        if (res.success) {
          let curReport = res.bean;
          this.setRouteParam({
            bizUuid:curReport.bizUuid,
            uuid:curReport.reportUuid || '',
            detailInfo:this.recordItem,
          });
          this.$u.route({
            url:'/pages/intelligence/intelligenceFilesAdd/clueReportInfo',
            type:'to',
            params:{
              delt: 2,
            },
          });
        } else {
          this.$u.toast(res.msg);
        }
      }).catch(e => {
        console.log(e);
        this.$modal.hideLoading();
      });
    },
    doTransfer(msg,record,type,tagOrgUuid) {
      this.$modal.confirm(msg,() => {
        this.$modal.showLoading('请稍后...');
        inteligenceService.clueTrans({uuid:record.uuid,type:type,tagOrgUuid,}).then(res => {
          this.$modal.hideLoading();
          if(res.success) {
            this.$u.toast('操作成功');
            this.downOrgVisible = false;
            this.backPrev({
              paramKey:"refresh",
              param: true,
            });
          } else {
            this.$u.toast(res.msg);
          }
        }).catch(e => {
          console.log(e);
          this.$modal.hideLoading();
          this.$u.toast('操作失败:' + e);
        });
      });
    },
    back(){
      this.backPrev({
        paramKey:"refresh",
        param: true,
      });
    },
    getUpdateActionBtns(){
      this.actionBtns = [];
      if(this.from == 0 || (this.from == 1 && this.recordItem.status == INTELLIGENCE_STATUS.DRAFT.value)){ // 新增
        this.actionBtns.push({
          text: '保存',
          action:'draft',
          plain: true,
          type: "primary",
        });
        this.actionBtns.push({
          text: '提交',
          action:'waitPoint',
          plain: false,
          type: "primary",
        });
        return;
      }
      if(this.fromType == 'feedback'){
        if(this.recordItem.status === INTELLIGENCE_STATUS.WAIT_INVEST.value ){ // 只有待调查状态可以进行调查
          this.actionBtns.push({
            text: '调查',
            action:'doInvest',
            plain: false,
            type: "primary",
          });
        }
        if(this.recordItem.status === INTELLIGENCE_STATUS.INVEST.value){
          this.actionBtns.push({
            text: '立案',
            action:'doRegCase',
            plain: true,
            type: "primary",
          });
        }
        if((this.recordItem.status === INTELLIGENCE_STATUS.INVEST.value && this.recordItem.current) || (this.recordItem.manager === 1 && this.recordItem.status !== 'stop' && this.recordItem.status !== 'feedback' && this.recordItem.status !== 'done' && this.recordItem.status !== 'draft')){
          this.actionBtns.push({
            text: '终止',
            action:'termination',
            plain: true,
            type: "error",
          });
        }
         if(this.recordItem.status === INTELLIGENCE_STATUS.STOP.value && (this.recordItem.current || this.recordItem.manager === 1)){
          this.actionBtns.push({
            text: '反馈',
            action:'feedback',
            plain: true,
            type: "primary",
          });
        }
      }else if(this.fromType == 'register'){
        if(this.recordItem.status === INTELLIGENCE_STATUS.STOP.value && (this.recordItem.current || this.recordItem.manager === 1)){
          this.actionBtns.push({
            text: '反馈',
            action:'feedback',
            plain: true,
            type: "primary",
          });
        }
        if((this.recordItem.status === INTELLIGENCE_STATUS.INVEST.value && this.recordItem.current) || (this.recordItem.manager === 1 && this.recordItem.status !== 'stop' && this.recordItem.status !== 'feedback' && this.recordItem.status !== 'done' && this.recordItem.status !== 'draft')){
          this.actionBtns.push({
            text: '终止',
            action:'termination',
            plain: true,
            type: "error",
          });
        }
      }
      if(this.recordItem.status == INTELLIGENCE_STATUS.DONE.value){
        this.actionBtns.push({
          text: '反馈详情',
          action:'feedbackDetail',
          plain: true,
          type: "primary",
        });  
      }
      if(this.from == 2){
        this.actionBtns.push({
          text: '接收登记',
          action:'accept',
          plain: false,
          type: "primary",
        });
      }else{
        if((this.recordItem.status === INTELLIGENCE_STATUS.AUDIT_DONE.value
          || this.recordItem.status === INTELLIGENCE_STATUS.INVEST.value
          || this.recordItem.status === INTELLIGENCE_STATUS.WAIT_INVEST.value
        ) && this.recordItem.current && this.fromType == 'register') {
          this.actionBtns.push({
            text: '指派',
            action:'invest',
            plain: false,
            type: "primary",
          });
        }
        if(
          (this.recordItem.status === INTELLIGENCE_STATUS.AUDIT_DONE.value || this.recordItem.status === INTELLIGENCE_STATUS.INVEST.value || this.recordItem.status === INTELLIGENCE_STATUS.WAIT_INVEST.value)
&& this.recordItem.manager === 1
&& this.fromType == 'register'
        ){
          this.actionBtns.push({
            text: '转办',
            action:'transfer',
            plain: false,
            type: "primary",
          });
        }
      }

      if(this.recordItem.resultHis){
        this.actionBtns.push({
          text: '调查记录',
          action:'feedbackHis',
          plain: false,
          type: "success",
        });
      }
    },
    transferAccept(){
      this.$refs.uForm.validate(valid => {
        if (valid) {
          this.$modal.showLoading('正在接收...');
          this.addForm.menuCode = "";
          this.addForm.status = INTELLIGENCE_STATUS.AUDIT_DONE.value;
          this.addForm.taskId = this.taskId;
          let tmpObj = Object.assign({}, this.addForm);
          tmpObj.isReport = tmpObj.isReport ? 1 : 0;
          inteligenceService.transferAccept(tmpObj).then(res => {
            this.$u.toast("接收成功");
            this.$modal.hideLoading();
            if(res.success){
              this.backPrev({
                paramKey:"refresh",
                param: true,
              });
            }else{
              this.$u.toast(res.msg);
            }
          }).catch(e => {
            this.$modal.hideLoading();
            console.log(e);
            this.$u.toast("保存失败");
          });
        }
      });
    },
    submitE(){
      this.$refs.uForm.validate(valid => {
        if (valid) {
          this.$modal.confirm(this.addForm.isReport ? "当前线索登记为举报是否确认提交?" : "当前线索登记为非举报是否确认提交?", () => {
            this.$modal.showLoading('正在提交...');
            this.addForm.menuCode = "";
            this.addForm.status = INTELLIGENCE_STATUS.AUDIT_DONE.value;
            let tmpObj = Object.assign({}, this.addForm);
            tmpObj.isReport = tmpObj.isReport ? 1 : 0;
            inteligenceService.clueSaveOrUpdate(tmpObj).then(res => {
              this.$modal.hideLoading();
              if(res.success){
                this.backPrev({
                  paramKey:"refresh",
                  param: true,
                });
              }else{
                this.$u.toast(res.msg);
              }
            }).catch(e => {
              this.$modal.hideLoading();
              console.log(e);
              this.$u.toast("保存失败");
            });
          });
        }
      });
    },
    feedback(){
      // 反馈
      this.$modal.showLoading('正在反馈...');
      inteligenceService.feedback({uuid:this.recordItem.uuid,}).then(res => {
        this.$modal.hideLoading();
        if(res.success) {
          this.backPrev({
            paramKey:"refresh",
            param: true,
          });
        } else {
          this.$u.toast(res.msg);
        }
      }).catch(e => {
        this.$modal.hideLoading();
        this.$u.toast('反馈失败' + e);
        console.log(e);
      });
    },
    btnAction(action, save){
      let msg = ''; let upOrgName = ''; let upOrgUuid = '';let isReport = false;
      switch(action){
      case 'draft':
        this.$refs.uForm.validate(valid => {
          if (valid) {
            this.$modal.showLoading('正在保存...');
            this.addForm.menuCode = "";
            this.addForm.status = INTELLIGENCE_STATUS.DRAFT.value;
            let tmpObj = Object.assign({}, this.addForm);
            tmpObj.isReport = tmpObj.isReport ? 1 : 0;
            inteligenceService.clueSaveOrUpdate(tmpObj).then(res => {
              this.$modal.hideLoading();
              if(res.success){
                // 修改原因： 新增情报管理-点击保存后页面跳转到上一层 fsx start
                this.recordItem = Object.assign({}, res.bean);
                this.fileUploadParam.bizId = this.recordItem.uuid;
                this.from = '1';
                this.fromType = "register";
                this.init();
                // 修改原因： 新增情报管理-点击保存后页面跳转到上一层 fsx end
                // this.backPrev({
                  // paramKey:"refresh",
                  // param: true,
                // });
              }else{
                this.$u.toast(res.msg);
              }
            }).catch(e => {
              this.$modal.hideLoading();
              console.log(e);
              this.$u.toast("保存失败");
            });
          }
        });
        break;
      case 'waitPoint':
        this.submitE();
        break;
      case 'transfer': // 转办
        if( this.topSelf === '-----') { // user.user.org.orgUuid;
          this.$modal.confirm('当前为省级局，是否将线索转办到国家局？选择是则将推送到国家局，选择否将展示省内专卖局选择界面','转办选择', () => {
            this.feedback();
          },() => {
            this.downOrgVisible = true;
          },'是','否');
        } else {
          this.downOrgVisible = true;
        }
        break;
      case 'accept': // 接收登记
        this.transferAccept();
        break;
      case 'invest':// 调查
        this.showMarketManager();
        break;
      case 'feedback':// 反馈
        this.$modal.confirm("是否进行反馈",() => {
          // this.feedback();
          this.$u.route("pages/intelligence/intelligenceFilesAdd/feedBackInfo",{formType:'feedback',uuid:this.recordItem.uuid,});
        });
        break;
      case 'feedbackDetail':// 反馈详情
        this.$u.route("pages/intelligence/intelligenceFilesAdd/feedBackInfo",{formType:'feedbackDetail',uuid:this.recordItem.uuid,});
        break;
      case 'doInvest':// 调查
        this.investVisible = true;
        break;
      case 'feedbackHis':// 反馈记录
        this.feedbackVisible = true;
        break;
      case 'immediateInvestigation':// 立即调查事件
        this.backPrev({
          paramKey:"refresh",
          param: true,
        });
        break;
      case 'doRegCase': // 立案
        if(this.recordItem.result != INVEST_STATUS.INVEST_01 && this.recordItem.result  !== INVEST_STATUS.INVEST_02){ // 立案  持续调查，立即调查不可立案
          return;
        }
        msg = '是否现在立案';
        if(this.recordItem.isReport == true || this.recordItem.isReport == 'true'){
          isReport = true;
        }
        this.$modal.confirm(msg, "提示", () => {
          this.setRouteParam({
            initQueryData:{
              clueUuid: this.recordItem.uuid,
              isReport: isReport,
              clueCode: this.recordItem.clueCode,
            },
          });
          this.$u.route({
            url:'/pages/case/components/caseFilingLink',
            type:'to',
            params:{
              caseType:CASE_TYPE.NORMAL,
              from:'qb',
            },
          });
        }, () => {
          this.setRouteParam({
            initQueryData:{
              clueUuid: this.recordItem.uuid,
              clueCode: this.recordItem.clueCode,
              isReport: isReport,
            },
          });
          this.$u.route({
            url:'/pages/case/components/caseFilingLink',
            type:'to',
            params:{
              caseType:CASE_TYPE.SIMPLE,
              from:'qb',
            },
          });
        }, '普通案件', '简易案件', '#000000', '#000000')
        // }
        break;
      case 'termination':// 终止记录
        this.$modal.confirm("是否终止调查此线索", () => {
          this.stopTask();
        });
        break;
      }
    },
    stopTask () {
      this.$modal.showLoading('终止中...');
      inteligenceService.stopClue({uuid: this.recordItem.uuid,}).then(res => {
        if (res.success) {
          this.$modal.hideLoading();
          this.backPrev({
            paramKey:"refresh",
            param: true,
          });
        } else {
          this.$modal.hideLoading();
          this.$u.toast(res.msg);
        }
      }).catch(err => {
        this.$modal.hideLoading();
        this.$u.toast(err);
      })
    },
  },
}
</script>

<style lang="scss" scoped>
	.page{
		padding: 0;
	}
	.nav-right-icon{
		margin-right: 30rpx;
		font-size: .8rem;
		color: #FFF;
	}
	.content{
		padding: $cm_conent_padding_column $cm_content_paddng_row;
	}
	.content-padding-bottom{
		padding-bottom: 150rpx !important;
	}
	.title-gp{
		font-size: 18rpx;
		color: $u-type-error;
	}
</style>
